<template>
  <span v-html="compLabel"></span>
</template>

<script lang="ts" setup>
//定义组件名称
// @ts-ignore
import {getCurrentInstance, onMounted, ref, watch} from "vue";

defineOptions({
  name: "DictLabel"
});
const props = defineProps({
  value: {type: Object, required: true},
  dictType: {type: String, required: true}
});

const compLabel = ref("");

onMounted(() => {
  getCompLabel();
})
// @ts-ignore
let {proxy} = getCurrentInstance()
watch(() => props.value, () => {
  getCompLabel();
})
const getCompLabel = () => {
  proxy.$http.post("/user-center/dict/findLabel", {
    value: props.value,
    dictType: props.dictType
  }).then((res: any) => {
    compLabel.value = res.data.label;
  });
}

</script>

<style scoped>

</style>